package com.vay.de.dang.online.util;

import android.content.Intent;
import android.text.style.ClickableSpan;
import android.view.View;

import com.vay.de.dang.online.ui.BaseActivity;
import com.vay.de.dang.online.ui.apply.CreditActivity;
import com.vay.de.dang.online.ui.my.PrivacyActivity;

public class ClickURLSpan extends ClickableSpan {

    private BaseActivity activity;
    private String url;
    private String param;

    public ClickURLSpan(BaseActivity activity, String url) {
        this.activity = activity;
        this.url = url;
    }

    public ClickURLSpan(BaseActivity activity, String url, String param) {
        this.activity = activity;
        this.url = url;
        this.param = param;
    }

    @Override
    public void onClick(View widget) {
        if (VnDefine.CreditPolicyUrl.equals(url)) {
            Intent intent = new Intent(activity, CreditActivity.class);
            intent.putExtra("param", param);
            activity.startActivity(intent);
        } else if (VnDefine.PrivacyPolicyUrl.equals(url)) {
            VnUIManager.nextActivity(activity, PrivacyActivity.class);
        }
    }
}
